app.directive('chartFirst',function () {
    return {
        scope: {
            id:'@',
            data:'='
        },
        restrict: 'E',
        template: '<div style="width:100%;height:300px;"></div>',
        replace: true,
        link: function($scope, element, attrs, controller) {
            var tempWeeks=new Array();//记录所you星期的数组；
            var tempYears=new Array();//记录所有年份的数组；
            var config1 = {
                grid:{
                    top: "15%",
                    height: "60%",
                },
                legend: {
                    top: "6rem",
                    data: ["安全生产预警指数","安全生产预测值"]
                },
                tooltip: {
                    trigger: 'axis'
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: $scope.data[0].week,
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#FFA27E'
                        }
                    }
                },
                series:[{
                    name: "安全生产预警指数",
                    type: "line",
                    data: $scope.data[0].spi
                },
                {
                    name: "安全生产预测值",
                    type: "line",
                    data: $scope.data[0].spifor
                }],
                yAxis: {
                    type: 'value'
                },
                dataZoom: [{
                    type: 'inside',
                    start: 70,
                    end: 100
                },{
                    type: "slider",
                    show: true,
                    bottom: "5rem",
                    handleSize: 30,
                    start: 70,
                    end: 100,
                    handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
                    handleSize: '80%',
                    handleStyle: {
                        color: '#ffffff',
                        shadowBlur: 3,
                        shadowColor: 'rgba(0, 0, 0, 0.6)',
                        shadowOffsetX: 2,
                        shadowOffsetY: 2
                    }
                }]
            };
            tempWeeks=$scope.data[0].week;
            tempYears=$scope.data[0].year;
            var chart1 = echarts.init(document.getElementById($scope.id));
            console.log($scope.id)
            chart1.setOption(config1);
        }
    }
})